package com.sqx.modules.goodsMessage.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.goodsMessage.entity.GoodsMessage;
import com.sqx.modules.goodsMessage.service.GoodsMessageService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品留言-管理端
 * @author wuChang
 * @since 2024-06-03
 */
@RestController
@Api(value = "商品留言-管理端", tags = {"商品留言-管理端"})
@RequestMapping("/admin/goodsMessage/")
public class GoodsMessageController {
    @Autowired
    private GoodsMessageService goodsMessageService;

    /**
     * 新增或修改商品留言
     *@param goodsMessage 商品留言
     */
    @ApiOperation("新增或修改商品留言")
    @PostMapping(value = "saveGoodsMessage")
    public Result saveGoodsMessage(@ApiParam("商品留言的实体")GoodsMessage goodsMessage) {
        return goodsMessageService.saveGoodsMessage(goodsMessage);
    }

    /**
     * 获取商品留言列表
     * @param goodsMessage 商品留言
     */
    @ApiOperation("获取商品留言列表")
    @GetMapping(value = "getGoodsMessageList")
    public Result getGoodsMessageList(@ApiParam("页数")Integer page,
                                      @ApiParam("条数")Integer limit,
                                      @ApiParam("商品留言的实体")GoodsMessage goodsMessage) {
        return Result.success().put("data", goodsMessageService.getGoodsMessageList(page, limit, goodsMessage));
    }

    /**
     * 删除商品留言
     *@param messageId 商品留言id
     */
    @ApiOperation("删除商品留言")
    @PostMapping(value = "deleteGoodsMessageById")
    public Result deleteGoodsMessageById(@ApiParam("商品留言id")Long messageId) {
        return goodsMessageService.removeById(messageId) ? Result.success() : Result.error();
    }


    /**
     * 获取商品留言详情
     *@param messageId 商品留言id
     */
    @ApiOperation("获取商品留言详情")
    @GetMapping(value = "getGoodsMessageById")
    public Result getGoodsMessageById(@ApiParam("商品留言id")Long messageId) {
        return Result.success().put("data", goodsMessageService.getById(messageId));
    }

    /**
     * 回复商品留言的列表
     */
    @ApiOperation("回复商品留言的列表")
    @GetMapping(value = "getReplyGoodsMessageList")
    public Result getReplyGoodsMessageList(@ApiParam("页数")Integer page,
                                           @ApiParam("条数")Integer limit,
                                           @ApiParam("商品留言的实体")GoodsMessage goodsMessage) {
        return Result.success().put("data", goodsMessageService.getReplyGoodsMessageList(page, limit, goodsMessage));
    }


}